//
//  main.cpp
//  TestHttplib
//
//  Created by huge on 2021/8/5.
//  Copyright © 2021 huge. All rights reserved.
//

#include <iostream>
#include "httplib.h"
#include <thread>

void requestServer(int val)
{
    // HTTP
//    httplib::Client cli("http://localhost:8088");
    httplib::Client cli("http://192.168.1.24:8080");
    //// HTTPS
    //    httplib::Client cli("https://cpp-httplib-server.yhirose.repl.co");
    
//    auto res = cli.Get("/hi");
    httplib::Headers* head = new httplib::Headers();
    auto res = cli.Get("/hi",httplib::Headers("head1","head2"));
//    cli.set_read_timeout(50000);
//    cli.set_connection_timeout(50000);
//    cli.set_write_timeout(50000);
//    cli.set_keep_alive(true);
    std::cout << res->status << "\t" << res->body << "\n";
    
}


int main(int argc, const char * argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    
    std::thread threadReq(requestServer,1);
    std::cout << "main thread wait you!" << std::endl;

    threadReq.join();

    return 0;
}
